package com.naiterui.ehp.bs.patient.service.impl;

import com.naiterui.ehp.bp.bo.consult.ComplaintBO;
import com.naiterui.ehp.bp.support.exception.BusinessException;
import com.naiterui.ehp.bs.patient.feign.IDoctorFeignClient;
import com.naiterui.ehp.bs.patient.repository.IApPatientRepository;
import com.naiterui.ehp.bs.patient.service.IConsultComplaintService;
import com.naiterui.ehp.bs.patient.vo.comment.ComplaintParamVO;
import com.naiterui.ehp.bs.wechat.service.ICustomMsgApiService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @Description 会话投诉
 * @Author gongbaoqiang
 * @Date 2020/7/1 6:01 PM
 */
@Service
public class ApConsultComplaintServiceImpl implements IConsultComplaintService {

    @Autowired
    private IDoctorFeignClient doctorFeignClient;
    @Autowired
    private IApPatientRepository patientRepository;
    @Autowired
    private ICustomMsgApiService customMsgApiService;

    @Override
    public void submit(Long patientId, ComplaintParamVO paramVO) throws BusinessException {
        ComplaintBO complaintBO = new ComplaintBO();
        BeanUtils.copyProperties(paramVO, complaintBO);
        complaintBO.setPatientId(patientId);
        doctorFeignClient.submitComplaint(complaintBO);

        //给患者发送投诉成功消息
        String openId = patientRepository.get(patientId).getOpenId();
        // customMsgApiService.sendSystemMsg(openId, ConfigUtil.getString("consult.comment.success.msg"));
    }

    @Override
    public Boolean existByConsultSession(Long consultSessionId, Integer type) throws BusinessException {
        return doctorFeignClient.existComplaintByConsultSession(consultSessionId, type);
    }
}
